package com.my.ubil;

import java.sql.*;

public class D8Con {
    public static final String url = "jdbc:mysql://localhost:3306/ab_hbook?characterEncoding=utf8";
    public static final String name = "com.mysql.cj.jdbc.Driver";
    public static final String user = "root";
    public static final String password = "123";
    private Connection con;

    public Connection getConnection() {

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ab_hbook?characterEncoding=utf8", "root", "123456");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch blook
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }

    public static void main(String[] args) {

        D8Con ab = new D8Con();
        System.out.println("con=" + ab.getConnection());
    }
}

